import basegraphunit from './basegraphunit.js'
import coorPkg from '../../struct/coord.js'

class Circle extends basegraphunit.BaseGraphUnit {
    constructor() {
        super();
        this.pos = new coorPkg.CirclePos();
        this.radius = 0;
        this.x = 0;
        this.y = 0;
        this.angle = 0;
    }

    translateSubInfo(tx,ty){
        this.x += tx;
        this.y += ty;
    }

    toJson() {
        var jsonobj = {};
        super.toJson(jsonobj);
        jsonobj["centerX"] = this.x;
        jsonobj["centerY"] = this.y;
        jsonobj["radius"] = this.radius;
        return jsonobj;
    }
    fromJson(obj) {
        super.fromJson(obj);
        this.x = obj["centerX"];
        this.y = obj["centerY"];
        this.radius = obj["radius"];

        this.pos.x = this.x;
        this.pos.y = this.y;
        this.pos.radius = this.radius;
    }

    cloneCopy() {
        var pNewInfo = new Circle();
        super.cloneCopy(pNewInfo);
        pNewInfo.x = this.x;
        pNewInfo.y = this.y;
        pNewInfo.radius = this.radius;
        return pNewInfo;
    }
}

export default { Circle }